package ui.test;

import org.testng.Assert;
import pages.HomePage;
import utils.LoggTest;

/**
 * Created with IntelliJ IDEA.
 * User: kvasolka
 * Date: 5/29/14
 * Time: 8:07 PM
 * To change this template use File | Settings | File Templates.
 */
public class CommonTestSteps extends BasicTest {

    public  void login(){
        HomePage page = new HomePage(driver);
        page.open();
        Assert.assertTrue(page.isOpen());
    }

    public void searchProduct(String productName){
        HomePage page = new HomePage(driver);
        Assert.assertTrue(page.searchProduct(productName), "PRODUCT NOT FOUND");
        LoggTest.info(String.format("PRODUCT %s IS FOUND", productName));
    }

    public void addProductToCompares(){
        HomePage page = new HomePage(driver);
        boolean returnValue = page.addProductToCompare();
        Assert.assertTrue(returnValue, "PRODUCT WAS NOT ADDED TO COMPARISON");
        LoggTest.info("PRODUCT WAS ADDED TO COMPARISON");
    }

    public void addProductToComparison() {
        HomePage page = new HomePage(driver);
        Assert.assertTrue(page.addProductToCompare());
    }

    public void isProductsCompared(String prod1,String prod2){
        HomePage page = new HomePage(driver);
        Assert.assertTrue(page.compareProducts(prod1, prod2));
    }

    public void searchNonFoundProduct(String productName) {
        HomePage page = new HomePage(driver);
        Assert.assertFalse(page.searchProduct(productName));
    }
}
